﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ManagedCuda.BasicTypes;
using ManagedCuda;
using ManagedCuda.CudaBlas;

namespace cudaMatrix
{

    public class BLASProvider
    {
        private static CudaBlas cublas;
        private static CudaContext ctx;
        private static CUdevice dev;
        private static CUdeviceptr pdev;

        private BLASProvider() { }

        public static CudaBlas Instance
        {
            get
            {
                if (cublas == null)
                {
                    ctx = new CudaContext(CudaContext.GetMaxGflopsDeviceId());
                    dev = ctx.Device;
                    pdev = new CUdeviceptr(dev.Pointer);
                    ctx.SetCurrent();
                    cublas = new CudaBlas();
                }
                return cublas;
            }
        }
    }
}
